OS   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 32
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A getInstance 0 7 3
1
import PackageManager from '../client/packageManager'
2
import Homebrew from '../client/packageManager/homebrew'
3
import ServiceCtl from '../client/serviceCtl'
4
import BrewServices from '../client/serviceCtl/brewServices'
5
6
7
export default class OS {
8
    private static instance: OS;
9
10
    operatingSystem: string
11
    packageManager: PackageManager
12
    serviceCtl: ServiceCtl
13
    services: null
14
    usrLocalDir: string
15
16
    private constructor() {
17
        switch (`${process.platform}_${process.arch}`) {
18
        case 'darwin_arm64':
19
            this.operatingSystem = 'darwin_arm64'
20
            this.packageManager = Homebrew.getInstance()
21
            this.serviceCtl = BrewServices.getInstance()
22
            this.services = null
23
            this.usrLocalDir = '/opt/homebrew'
24
            break
25
        default: // darwin x64
26
            this.operatingSystem = 'darwin_x64'
27
            this.packageManager = Homebrew.getInstance()
28
            this.serviceCtl = BrewServices.getInstance()
29
            this.services = null
30
            this.usrLocalDir = '/usr/local'
31
            break
32
        }
33
    }
34
35
    public static getInstance(): OS {
36
        if (!OS.instance) {
37
            OS.instance = new OS()
38
        }
39
40
        return OS.instance
41
    }
42
}
43